package com.taotao.patient.controller;

import com.taotao.common.core.domain.Result;
import com.taotao.patient.domain.request.GroupRequest;
import com.taotao.patient.domain.request.MessageRequest;
import com.taotao.patient.domain.response.GroupResponse;
import com.taotao.patient.domain.response.MessageResponse;
import com.taotao.patient.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: PatientController
 * @author: ZhangYuQi
 * @date: 2025/2/24 下午7:52
 * @Version: 1.0
 * @description:
 */

@RestController
public class PatientController {

    @Autowired
    private PatientService patientService;


    /**
     * @return
     * @Author ZhangYuQi
     * @Description 查询当前登录医生下所有的分组和患者
     * @Date 上午11:00 2025/2/25
     * @Param []
     */
    @GetMapping("selectGroupsAndPatients")
    Result<List<GroupResponse>> selectGroupsAndPatients() {
        return Result.success(patientService.selectGroupsAndPatients());
    }


    /**
     * @return
     * @Author ZhangYuQi
     * @Description 新增分组
     * @Date 上午11:05 2025/2/25
     * @Param [groupName]
     */
    @GetMapping("insertGroup/{groupName}")
    Result insertGroup(@PathVariable String groupName) {
        patientService.insertGroup(groupName);
        return Result.success();
    }

    /**
     * @return
     * @Author ZhangYuQi
     * @Description 删除分组
     * @Date 上午11:06 2025/2/25
     * @Param [groupId]
     */
    @DeleteMapping("deleteGroup/{groupId}")
    Result deleteGroup(@PathVariable Long groupId) {
        patientService.deleteGroup(groupId);
        return Result.success();
    }


    /**
     * @return
     * @Author ZhangYuQi
     * @Description 群发消息
     * @Date 上午11:49 2025/2/25
     * @Param [request]
     */
    @PostMapping("insertMessage")
    public Result insertMessage(@RequestBody MessageRequest request) {
        patientService.insertMessage(request);
        return Result.success();
    }

    /**
    * @Author ZhangYuQi
    * @Description 查询历史群发消息
    * @Date 上午11:56 2025/2/25
    * @Param
    * @return
    */
    @GetMapping("selectMessageHistory")
    public Result<List<MessageResponse>> selectMessageHistory() {

        return Result.success(patientService.selectMessageHistory());
    }


    /**
    * @Author ZhangYuQi
    * @Description 患者分组
    * @Date 下午2:19 2025/2/25
    * @Param [request]
    * @return
    */
    @PostMapping("insertGroupUser")
    public Result insertGroupUser(@RequestBody GroupRequest request) {
        patientService.insertGroupUser(request);
        return Result.success();
    }



}
